codefandomcom-20200214-history
Algol 60
Algol 60 was the first structured programming language containing blocks whose range defined the scope of variables, i.e. the variables declared within the block was accessible for code statements within that block only: begin integer A, X; comment outer X; A := 3; X := 5; begin integer X, Y; comment inner X; X := 4; comment inner X assigned here; Y := 8; end print (X); comment prints "5", not "4" since this is outer scope; Y := 12; comment illegal! Y not defined in outer scope; end; This kind of declaration scope was introduced with Algol 60, and soon became the programming language standard of the many programming languages in the Algol class. Notable exception was BASIC, introduced after Algol, yet having no declaration scope. History An earlier Algol 58, also called IAL, was defined by IFIP (International Federation for Information Processing), but this language was so heavily reworked during 1960 that the new language Algol 60 was essentially a new language. Algol 58 didn't have blocks. Algol 60 was popular both for algorithm publishing, and by implementations of which none was really compatible to any other implementation. Many Algol 60 derived languages occured for a long time. In 1967 Dahl and Nygaard published the last grand Algol 60, called Simula 67. It contained classes that was later copied by Stroustrup into C++. In 1968 IFIP published a new language called Algol 68. The new language was nothing like any earlier Algol and was heavily criticised for being an entirely new language with no abstractions inherited from Algol 60, and for being very hard to implement. Thereby the Algol 60 chain was essentially broken, but some superficial traits from Algol 60 were borrowed over to the language BCPL and it's extremely successful successor C. Hello world Essentially a hello world couldn't be written in Algol 60 since there was no printout subroutine defined in the language. However, presuming that a local implementation had the function outstring() – after the Simula 67 pattern – a hello world could look like: begin outstring(‘Hello world!’) end; Language Blocks and scope The language contained blocks starting with and ending with . Statements were separated by semicolon, statements were not ended by semicolon like in C – this might seem a ridiculous distinction but compare Algol-60 begin integer X; X := 23 end with C:s counterpart {''' '''int X; X = 23';' }''' A semicolon after 23 is optional in Algol-60, making the variant '''begin integer X; X := 23';' end optional, while the statement {''' '''int X; X = 23 }''' where the final 23 is '''not followed by a semicolon is illegal! Data types Scalars Algol 60 had the scalar datatypes , , and . and had operators and functions: arithmetic: :+ plus - minus × times / division ÷ integer division ↑ exponentiation abs(x) absolute value sign(x) signum entier(x) ceiling sqrt(x) square root exp(x) ex ln(x) natural logarithm sin(x) sine cos(x) cosine arctan(x) arcus tangent comparisons: :< less ≤ less or equal = equal ≥ greater or equal > greater ≠ not equal logic operators: :≡ equivalence ⊃ implication ∧ and ∨ or ¬ not Algol was defined before ASCII, and so did use many exotic characters that became generally available for everyone only when Unicode was established on the computer market. There were never any functions defined for pure Algol 60. Simula defined a vast set of character, string and set functions. Arrays Arrays of s and s could be defined according to the pattern: integer array Astart:end; or real array Astart:end; or just array Astart:end; in which case was defaulted. Array elements were accessed in the modern way: A4 or Ax Switches was a weird array data type containing jump labels. Such arrays could be used indexed as a label statement in a clause, such as go to SN jumping to a position determined by the contents of switch S at the index position of N. This was later on declared evil by many PL designers and programmers, since the jump destination is not easily predictable by any program analysator. Switches were retained for compatibility in Simula 67, but made did never occur in any other programming language. The switches of C and other curly-braces-PL:s are quite dissimilar, and would in non-curly languages be called select clauses. Category:Procedural programming languages